package com.stu.common.utils;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;

public class DataInsertUtil {

    private static final Random random = new Random();

    public static Map<String,String> GenerateName() {//生成男性姓名

        //姓
        String[] surName=new String[]{"赵","孙","吴","王","韩","周","陈","李","洪","孔"};
        //男性
        String[] name1=new String[]{"铭","小","子","贤","御","鹏","泽","波","伟","宝",
                "东","刚","峰","波","俊","道"};
        String[] name2=new String[]{"蔚","明","李","楠","岳","鹏","鸿","良","境","瑾",
                "鑫","悦","云","波","端","斌"};
        String[] name3 = new String[]{"茂", "有","立", "君", "友", "骅", "骞", "向", "兴", "纯",
                "连", "继", "磊", "宁", "扬", "欣"};
        String[] name4 = new String[]{"马", "诚","宗", "政", "江", "子", "来", "凌", "翔", "怀",
                "洲", "刚", "松", "胜", "汉", "家"};
        //女性
        String[] name5 = new String[]{"允", "元","源", "渊", "和", "函", "妤", "宜", "云", "琪",
                "菱", "宣", "健", "信", "媛", "伊"};
        String[] name6 = new String[]{"珍", "依","沫", "玉", "灵", "瑶", "嫣", "倩", "妍", "萱",
                "漩", "娅", "怡", "媛", "淇", "娜"};
        String[] name7 = new String[]{"婉", "娴","瑾", "颖", "瑶", "露", "怡", "婵", "雁", "菁",
                "岚", "苑", "梦", "馨", "毓", "蕊"};
        String[] name8 = new String[]{"欣", "育","涵", "晴", "琴", "美", "丽", "倩", "悦", "彤",
                "影", "茜", "希", "夕", "思", "昭"};



        String firstName = surName[(int) (Math.random() * 10)];
        String sonName = firstName + name1[(int) (Math.random() * 16)] + name2[(int) (Math.random() * 16)];
        String daughterName = firstName + name5[(int) (Math.random() * 16)] + name6[(int) (Math.random() * 16)];
        String fatherName = firstName + name3[(int) (Math.random() * 16)] + name4[(int) (Math.random() * 16)];
        String motherName = surName[(int) (Math.random() * 10)] + name7[(int) (Math.random() * 16)] + name8[(int) (Math.random() * 16)];

        Map<String, String> map = new HashMap<>();
        map.put("son", sonName);
        map.put("daughter", daughterName);
        map.put("father", fatherName);
        map.put("mother", motherName);
        return map;

    }

    public static String GeneratePhone(){//生成手机号码
        String[] num1 = new String[]{"5", "3"};
        String[] num2=new String[]{"1","2","3","4","5","6","7","8","9","0"};

        return "1"+num1[(int)(Math.random()*2)]+num2[(int)(Math.random()*10)]+"15"+num2[(int)(Math.random()*10)]+"51"+num2[(int)(Math.random()*10)]
                +num2[(int)(Math.random()*10)]+num2[(int)(Math.random()*10)];
    }


    public static Map<String,Object> GenerateUid(){//生成身份证+年龄
        String[] num1 = new String[]{"1", "2","3","4"};
        String[] num2=new String[]{"1","2","3","4","5","6","7","8","9","0"};
        String[] num3=new String[]{"1","2","3","4","5","6","7","8","9"};
        String[] num4 = new String[]{"1", "2","0"};

        String year = "200" + num1[(int) (Math.random() * 4)];
        String month = "0" + num3[(int) (Math.random() * 9)];
        String day = num4[(int) (Math.random() * 3)] + num3[(int) (Math.random() * 9)];
        String uid = "350700" + year + month + day + num2[(int) (Math.random() * 10)] + num2[(int) (Math.random() * 10)] + num2[(int) (Math.random() * 10)] + num2[(int) (Math.random() * 10)];

        //换算成年龄当前年-year
        Calendar calendar=Calendar.getInstance();
        int nowYear = calendar.get(Calendar.YEAR);
        int age = nowYear - Integer.parseInt(year);

        Map<String, Object> map = new HashMap<>();
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        if (age==18) {
            LocalDateTime dateTime=  LocalDateTime.parse(String.valueOf(nowYear)+"-06-01 00:00:00",dateTimeFormatter);
            map.put("stime",dateTime);
        }
        if (age==19) {
            LocalDateTime dateTime=  LocalDateTime.parse(String.valueOf(nowYear-1)+"-06-01 00:00:00",dateTimeFormatter);
            map.put("stime",  dateTime);
        }
        if (age==20) {
            LocalDateTime dateTime= LocalDateTime.parse(String.valueOf(nowYear-2)+"-06-01 00:00:00",dateTimeFormatter);
            map.put("stime", dateTime);
        }
        if (age==21) {
            LocalDateTime dateTime= LocalDateTime.parse(String.valueOf(nowYear-3)+"-06-01 00:00:00",dateTimeFormatter);
            map.put("stime", dateTime);
        }
        map.put("uid", uid);
        map.put("year", year);
        map.put("month", month);
        map.put("day", day);
        map.put("age", age);
        LocalDateTime dateTime= LocalDateTime.parse(year + "-" + month + "-" + day+" 00:00:00",dateTimeFormatter);
        map.put("birth", dateTime);
        return map;
    }

    public static String GenerateAddress(){//生成地址
        String[] num1 = new String[]{"樟城", "城峰","葛岭","清凉","大洋"};
        String[] num2=new String[]{"白云","丹云","西溪","北门","岭路","东门","盖洋","同安","富泉","红星"};

        return "福建省福州市永泰县"+num1[(int)(Math.random()*5)]+"镇"+num2[(int)(Math.random()*10)]+"村";
    }



    public static void main(String[] args) {


        for (int i=0;i<100;i++)
        System.out.println(GenerateUid());


       /* LocalDateTime dateTime=LocalDateTime.parse("2021-01-02 10:00:00", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));

        System.out.println(dateTime);*/
    }
}


